<template>
	<view>
		<view class="tabs-style">
			<view class="tab-style" :class="{active: isVip}" @click="showVip">
				<uni-icons type="person" size="18" color="inherit"></uni-icons>
				我的邀请列表
			</view>
			<view  class="tab-style" :class="{active: !isVip}" @click="showCode" v-if="userInfo.is_admin === 1">
				<uni-icons type="paperclip" size="18" color="inherit"></uni-icons>
				邀请码列表🏅
 			</view>
		</view>
		<!-- 内容区域 -->
		<view v-if="isVip">
			<VipList :member-list="memberList"></VipList>
		</view>
		<view v-else>
			<CodeList></CodeList>
		</view>
	</view>
</template>

<script>
	import VipList from '@/pages/admin/memberManage/components/vipList.vue'
	import CodeList from '@/pages/admin/memberManage/components/codeList.vue'
	import {
		userApi
	} from '../../../utils/api'
	export default {
		components: {
			VipList,
			CodeList
		},
		data() {
			return {
				isVip: true,
				page: 1,
				memberList: [],
				userInfo:{},
			}
		},
		onLoad() {
			this.getusers();this.getUserInfo();
		},
		onReachBottom() {
			this.page += 1;
			this.isVip && this.getusers();
		},
		methods: {
			getUserInfo(){
		userApi.getUserInfo().then((res)=>{
			this.userInfo =  res.data;
			uni.setStorageSync('userInfo',res.data);
		})
	},
			getusers() {
				userApi.getMySonUsers({
					page: this.page,
					pageSize: 10
				}).then((res) => {
					if (this.page === 1) {
						this.memberList = [];
					}
					res.data.forEach((item) => {
						item.vipType = item.vip_type;
						this.memberList.push(item)
					})
				})
			},
			showVip() {
				this.isVip = true
				this.page = 1;
				this.getusers();
			},
			showCode() {
				this.isVip = false
				this.page = 1;
				this.getusers();
			}
		}
	}
</script>

<style scoped>
	.tabs-style {
		display: flex;
		gap: 20rpx;
		padding: 20rpx;
		background: #f8f9fa;
	}

	.tab-style {
		flex: 1;
		height: 100rpx;
		border-radius: 12rpx;
		font-size: 30rpx;
		font-weight: 500;
		display: flex;
		align-items: center;
		justify-content: center;
		gap: 12rpx;
		color: #606266;
		background: #fff;
		transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
		box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);


	}



	::v-deep .vip-card {
		margin: 20rpx;
		padding: 24rpx;
		background: #fff;
		border-radius: 16rpx;
		box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
		display: flex;
		align-items: center;
		transition: transform 0.2s;
	}

	::v-deep .vip-card:active {
		transform: scale(0.98);
	}


	::v-deep .status-badge {
		padding: 4rpx 12rpx;
		border-radius: 20rpx;
		font-size: 24rpx;
		margin-left: auto;
	}

	::v-deep .status-active {
		background: #e8f5e9;
		color: #2b9939;
	}

	::v-deep .status-expired {
		background: #ffebee;
		color: #f44336;
	}
</style>